import pandas as pd
import matplotlib.pyplot as plt

plt.rcParams['font.family'] = 'SimHei'

file_path_profit = '../雪龙集团现金流量表.xlsx'
df_profit_corrected = pd.read_excel(file_path_profit, header=None)

df_profit_corrected.columns = ["项目"] + [2020, 2021, 2022, 2023]

for col in [2020, 2021, 2022, 2023]:
    df_profit_corrected[col] = pd.to_numeric(df_profit_corrected[col].replace(',', '', regex=True), errors='coerce')

metrics_to_plot_corrected = ['经营活动现金流量净额(元)']
data_for_plot_corrected = df_profit_corrected[df_profit_corrected["项目"].isin(metrics_to_plot_corrected)]

plt.figure(figsize=(10, 6))
for _, row in data_for_plot_corrected.iterrows():
    plt.plot([2020, 2021, 2022, 2023], row[1:], marker='o', label=row["项目"])

# Add chart title and labels
plt.title("雪龙集团2020-2023年经营活动现金流量净额(元)折线图", fontsize=16)
plt.xlabel("年份", fontsize=12)
plt.ylabel("金额（百万元）", fontsize=12)

plt.legend(loc="best", fontsize=10)
plt.grid(alpha=0.5)
plt.tight_layout()
plt.savefig('../分析图象/经营活动现金流量净额图像.png')

plt.show()
